package com.matea.order.message;

import com.matea.order.dto.OrderDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class StreamReceiver {

//    @StreamListener(StreamClient.INPUT)
//    @SendTo(StreamClient.OUTPUT)
//    public Object processInput(Object message){
//        log.info("StreamReceiver:{}",message);
//        return  message;
//    }

//   @StreamListener(StreamClient.OUTPUT)
//    public  void process(String message){
//        log.info("**************************** StreamReceiver:{}",message);
//    }

    /**
     * 接收orderDTO对象
     * @param message
     */
    @StreamListener(StreamClient.INPUT)
    @SendTo(StreamClient.INPUT2)
    public  String process(OrderDTO message){
        log.info("**************************** StreamReceiver:{}",message);
        return "receiverd.";
    }

    @StreamListener(StreamClient.INPUT2)
    public  void process2(String message){
        log.info("**************************** StreamReceiver:{}",message);
    }
}
